package com.heyqing.medium.day13;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * ClassName:MinStack
 * Package:com.heyqing.medium.day13
 * Description:
 *
 * @Date:2024/10/15
 * @Author:Heyqing
 */
public class MinStack {

    private List<Integer> list;

    public MinStack() {
        list = new ArrayList<>();
    }

    public void push(int x) {
        list.add(x);
    }

    public void pop() {
        if (list.isEmpty()) return;
        list.remove(list.size() - 1);
    }

    public int top() {
        return list.get(list.size() - 1);
    }

    public int getMin() {
        return Collections.min(list);
    }
}
